<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
	<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<base href="${BaseContext }">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<!-- 引入bootstrap -->
	<link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="static/css/bootstrap-select.css">
	<!-- 引入JQuery  bootstrap.js-->
	<script src="static/js/jquery-3.2.1.min.js"></script>
	<script src="static/js/bootstrap.min.js"></script>
	<script src="static/js/bootstrap-select.js"></script>
	<script src="static/js/defaults-zh_CN.js"></script>
</head>
<body>
	<!-- 顶栏  -->
	<jsp:include page="include/top.jsp"></jsp:include>
	<div class="container" id="content">
		<div class="row">
			<!-- 菜单 -->
			<jsp:include page="include/menu.jsp"></jsp:include>
			<div class="col-md-10">
				<div class="panel panel-default">
				    <div class="panel-heading">
						<div class="row">
					    	<h3 class="col-md-5">课程管理</h3>
							<!-- 按照学院查询教师 -->
							<form class="bs-example bs-example-form col-md-4" id="gradeForm" role="form" style="margin: 20px 0 10px 0;" action="admin/manageCourseSchedule.do" method="post">
								<select class="selectpicker" id="grade-select" name="tGrade">
									<option value="0">---请选择院系---</option>
									<c:forEach items="${gradeModels }" var="grade">
										<option value="${grade.gId }" <c:if test="${tGrade==grade.gId}">selected</c:if>>${grade.gName }</option>
									</c:forEach>
								</select>
							</form>
								<button class="btn btn-default col-md-1" style="margin-top: 20px" onclick="selectByGrade()">
									搜索
								</button>
							
							<!-- 翻页form -->
							<form id="hiddenForm" action="admin/manageCourseSchedule.do"
								method="post">
								<input type="hidden" name="pageNum" id="pageNum">
								<input type="hidden" name="tGrade" value="${tGrade}">
							</form>
							
						</div>
				    </div>
					    <table class="table table-bordered">
							<thead>
								<tr>
									<th>教师编号</th>
									<th>姓名</th>
									<th>性别</th>
									<th>出生年份</th>
									<th>学历</th>
									<th>职称</th>
									<th>学院</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${pageInfo.list}" var="teacher">
									<tr>
										<td>${teacher.tId}</td>
										<td>${teacher.tName}</td>
										<td><c:if test="${teacher.tSex==0 }">男</c:if> <c:if
												test="${teacher.tSex==1 }">女</c:if></td>
										<td><fmt:formatDate value="${teacher.tBirth}"
												dateStyle="medium" /></td>
										<td><c:if test="${teacher.tDgree==0 }">本科</c:if> <c:if
												test="${teacher.tDgree==1 }">硕士</c:if> <c:if
												test="${teacher.tDgree==2 }">博士</c:if></td>
										<td><c:if test="${teacher.tTitle==0 }">教师</c:if> <c:if
												test="${teacher.tTitle==1 }">助教</c:if> <c:if
												test="${teacher.tTitle==2 }">副教授</c:if> <c:if
												test="${teacher.tTitle==3 }">教授</c:if></td>
										<td>${teacher.gradeModel.gName}</td>
										<td>
											<button class="btn btn-default btn-xs btn-primary 
												<c:if test='${not empty teacher.courseModel.courseId }'>btn-success</c:if>
												<c:if test='${empty teacher.courseModel.courseId }'>btn-warning</c:if> "
												onClick="classPlan(this);">课程详情</button>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
				</div>
				<!-- 页码 -->
				<jsp:include page="include/pageInfo.jsp"></jsp:include>
				    
				</div>
			</div>
		</div>
	</div>
	<!-- footer -->
	<jsp:include page="include/footer.jsp"></jsp:include>
</body>
<script type="text/javascript">
	$("#nav li:nth-child(3)").addClass("active");
	 /* 翻页按钮 */
    function goPage(page){
		$("#pageNum").val(page);
		$("#hiddenForm").submit();
	}
	/* 搜索按钮 */
	function selectByGrade(){
		/*alert($('#gradeForm').serialize());*/
		$("#gradeForm").submit();
	}
	function classPlan(obj){
		var tId = $(obj).parent().parent().children().eq(0).text();
		var tName = $(obj).parent().parent().children().eq(1).text();
		var tGradeName = $(obj).parent().parent().children().eq(6).text();
		/* alert(tId+'::'+tName+'::'+tGrade); */
		window.location.href = "admin/courseSchedule.do?tId="+tId+"&tName="+tName+"&tGradeName="+tGradeName;
		/* $.post('admin/courseSchedule.do',{tId:tId,tName:tName,tGradeName:tGradeName}); */
	}
</script>
</html>